<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\User;
class UserController extends Controller
{
    /**
     * @return string
     */
    public function user()
    {
        return $users = new User();
    }

    /**
     * 用户列表
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function getTable()
    {
        $data = User::all();
        return view('admin/userTable', ['data' => $data]);
    }

    /**
     * 添加用户表单
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function getForm()
    {
        return view('admin/userForm');
    }

    /**
     * 修改信息表单
     * @param $id
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function getUpdateForm($id)
    {
        $data = User::where('id', $id)->get();
        return view('admin/userForm', ['data' => $data]);
    }

    /**
     *软删除(回收操作)
     * @param $id
     * @return \Illuminate\Http\RedirectResponse
     */
    public function getDelete($id)
    {
        $this->user()->userDelete($id);
        return redirect('admin/table');
    }
}
